<div class="span3">
	<h4 class="title"><?= $title; ?></h4>
	<div class="box nopad">
	    <div class="accordion aktuellt_box" id="accordion2">
	        <?php 
	            // News titles loop
	        $counter = 0;
	        foreach($articles as $n) : 
	            ?>
	        <div class="accordion-group">
	            <div class="accordion-heading">
	                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse<?php echo $counter;?>">
	                    <strong><?php echo $n->headline;?></strong><br/>
	                    <?php echo $n->datum;?>
	                </a>
	            </div>
	            <div id="collapse<?php echo $counter;?>" class="accordion-body collapse out">
	                <div class="accordion-inner">
	                    <?= getContentz($n, false); ?>
	                </div>
	            </div>
	        </div>
	        <?php 
	        $counter ++;
	        endforeach; 
	        ?>
	    </div>
	</div>
</div>

<?php 
function getContentz($article, $fulltext){
	$rmo = "[readmore]";
	$link = "<a href='/nyheter/$article->id'>&raquo; Läs mer</a>";
	
	if($fulltext) {
		return str_replace($rmo, '', $article->content);
	} else {
		$text = $article->content;
		if(strpos($text, $rmo) > 0){
			$text = substr($text, 0, strpos($text, $rmo) + strlen($rmo));
		}
		return str_replace($rmo, $link, $text);
	}
}
?>